% Reads in an edi file
% latest date 17.4.3

function[tf1] = readedi(fname);

if nargin < 1,
    fname = '*.edi';
else,
    fname = [fname '*.edi'];
end;

ProcDef.equations=[4 1 2;5 2 1];
ProcDef.neq = 2;
ProcDef.rreqn = [4 1 2 6 7;5 2 1 7 6];

[file,path] = uigetfile(fname, 'Open EDI file');

if file == 0,
K = 2;
return;
end;
line1 = [path file];
fid = fopen(line1,'rt'); 

[SPM,er]=edi_in(fid);

ProcDef.nfrq=length(SPM.spectra);
ProcDef.TLFreq1=SPM.head.frq; 
ProcDef.file1=file;
nchan = length(SPM.spectra(1).data);
tf1 = TransFn(SPM,ProcDef);
figure(1);
[Rhxy Rhyx Phxy Phyx] = dispresph(tf1,ProcDef);
%dummy(tf1,frq,file);
if nchan == 7,
tf1 = tf_r(SPM);
figure(2);
[Rhxy Rhyx Phxy Phyx] = dispresph(tf1,ProcDef);
end;   
